<template>
  <view class="my-userInfo-box">
    <!-- 用户头像，昵称区域 -->
    <view class="userInfo-box">
      <image :src="userLogin.avatarUrl" class="user-img"></image>
      <view class="user-text">{{userLogin.nickName}}</view>
    </view>
    <!-- 面板区域 -->
    <view class="panel-userInfo-box">
      <!-- 第一面板区域 -->
      <view class="panel-list">
        <view class="panel-body">
          <view class="panel-item">
            <text>8</text>
            <text>收藏的店铺</text>
          </view>
          <view class="panel-item">
            <text>14</text>
            <text>收藏的商品</text>
          </view>
          <view class="panel-item">
            <text>18</text>
            <text>关注的商品</text>
          </view>
          <view class="panel-item">
            <text>84</text>
            <text>足迹</text>
          </view>
        </view>
      </view>
      <!-- 第二面板区域 -->
      <view class="panel-list">
        <view class="user-ld">我的订单</view>
        <view class="panel-body">
          <view class="panel-item" >
            <image src="/static/my-icons/icon1.png" class="icon-img"></image>
            <text>待付款</text>
          </view>
          <view class="panel-item">
            <image src="/static/my-icons/icon2.png" class="icon-img"></image>
            <text>待收货</text>
          </view>
          <view class="panel-item">
            <image src="/static/my-icons/icon3.png" class="icon-img"></image>
            <text>退款/退货</text>
          </view>
          <view class="panel-item">
            <image src="/static/my-icons/icon4.png" class="icon-img"></image>
            <text>全部订单</text>
          </view>
        </view>

      </view>
      <!-- 第三面板区域 -->
      <view class="panel-list">
        <view class="third-panel-item">
          <text>收货地址</text>
          <uni-icons type="right" size="16"></uni-icons>
        </view>
        <view class="third-panel-item">
          <text>联系客服</text>
          <uni-icons type="right" size="16"></uni-icons>
        </view>
        <view class="third-panel-item" @click="LoginOut">
          <text>退出登录</text>
          <uni-icons type="right" size="16"></uni-icons>
        </view>
      </view>
    </view>

  </view>
</template>

<script>
  import {
    mapState,mapMutations
  } from 'vuex'
  export default {
    name: "my-userInfo",
    data() {
      return {

      };
    },
    computed: {
      ...mapState('m_userInfo', ['userLogin'])
    },
    methods:{
      ...mapMutations('m_userInfo',['updateaddressList','updateUserInfo','updateToken']),
     async LoginOut(){
     const [err,succ] = await uni.showModal({
          title:'退出',
          content:'确认退出登录吗？' 
        }).catch(err => err)
        console.log(succ)
        // 用户确认了退出登录后，清空数据
         if(succ && succ.confirm){
           this.updateaddressList({}),
           this.updateUserInfo({}),
           this.updateToken('')
         } 
      }
    }
  }
</script>

<style lang="scss">
  .my-userInfo-box {
    height: 100vh;
    background-color: #f4f4f4;

    //用户昵称
    .userInfo-box {
      height: 400rpx;
      background-color: #C00000;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;

      .user-img {
        display: block;
        width: 90px;
        height: 90px;
        border: 2px solid white;
        box-shadow: 0 1px 3px black; //设置阴影
        border-radius: 45px;
      }

      .user-text {
        margin-top: 15px;
        font-size: 16px;
        font-weight: bold;
        font-family: "宋体";
        color: white;
      }
    }

    //面板区域(由于第一块和第二块面板所需样式差不多，所用都在一个panel-body类样式来便于页面样式处理)
    .panel-userInfo-box {
      padding: 0 10px;
      position: relative;
      top: -10px;

      //第一个面板区域
      .panel-list {
        background-color: white;
        margin-bottom: 8px;
        border-radius: 5px;
        .panel-body {
          display: flex;
          justify-content: space-around;
          .panel-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: space-around;
            font-size: 14px;
            padding: 8px 0px;
            .icon-img {
              width: 35px;
              height: 35px;
              margin-bottom: 5px;
            }
          }
        }
        .user-ld{
          padding:10px 10px;
          border-bottom: 1px solid #efefef;
        }
      }

      //第三个面板
      .third-panel-item{
        display: flex;
        justify-content: space-between;
        padding: 10px 10px;
        border-bottom: 1px solid #efefef;
        align-items: center;
      }
    }
  }
</style>
